<?php

namespace backend\models;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\models\PrfScoreExchange;
use yii\data\Sort;

/**
 * SysItemSearch represents the model behind the search form about `backend\models\SysItem`.
 */
class ScoreExchangeSearch extends PrfScoreExchange {
	
/**
     * @inheritdoc
     */
		 public function rules()
		    {    	
		       return [
			 [['item_id'], 'integer'],
            [['title'], 'string', 'max' => 255]
		        ];
		    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
    	$query = PrfScoreExchange::find();
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
	        'pagination'=>['pageSize' => '10'],
        ]);
 
        $this->load($params);
        if (!$this->validate()) {
            return $dataProvider;
        }

        $query->andFilterWhere([
            'id' => $this->id 
        ]);
        $query->andFilterWhere(['like', 'title', $this->title]) 
           ;
        return $dataProvider;
    }
    
}
